home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / var / lib / dpkg / info / hdparm.preinst < prev    next >
Encoding:
Text File  |  2007-03-04  |  1.6 KB  |  50 lines

  1. #!/bin/sh
  2.  
  3. # Remove a no-longer used conffile
  4. rm_conffile() 
  5. {
  6.   CONFFILE="$1"
  7.  
  8.   if [ -e "$CONFFILE" ]; then
  9.     md5sum="`md5sum \"$CONFFILE\" | sed -e \"s/ .*//\"`"
  10.     old_md5sum="`sed -n -e \"/^Conffiles:/,/^[^ ]/{\\\\' $CONFFILE'{s/.* //;p}}\" /var/lib/dpkg/status`"
  11.     if [ "$md5sum" != "$old_md5sum" ]; then
  12.       echo "Obsolete conffile $CONFFILE has been found, but is modified or has unknown md5sum"
  13.       echo "Saving as $CONFFILE.dpkg-bak ..."
  14.       mv -f "$CONFFILE" "$CONFFILE".bak
  15.     else
  16.       echo "Removing obsolete conffile $CONFFILE ..."
  17.       rm -f "$CONFFILE"
  18.     fi
  19.   fi
  20. }
  21.  
  22. if [ "$1" = install ] || [ "$1" = upgrade ]; then
  23.   if dpkg --compare-versions "$2" lt 6.3-3ubuntu1; then
  24.       rm_conffile /etc/init.d/hdparm
  25.       update-rc.d -f hdparm remove >/dev/null 2>&1
  26.   fi
  27.  
  28.   if dpkg --compare-versions "$2" le 6.1-6; then
  29.     if dpkg --compare-versions "$2" gt 6.1-2; then
  30.       for conffile in /etc/init.d/hdparm.dev /etc/default/hdparm /etc/dev.d/block/hdparm.block /etc/dev.d/block/hdparm.dev; do
  31.         [ ! -e "$conffile" ] || rm_conffile "$conffile"
  32.       done
  33.     elif dpkg --compare-versions "$2" lt 5.5-5; then
  34.       update-rc.d -f hdparm remove > /dev/null 2>&1
  35.       if dpkg --compare-versions "$2" lt 5.4-6; then
  36.         [ ! -e /etc/hdparm.conf ] || rm_conffile "/etc/hdparm.conf"
  37.         if dpkg --compare-versions "$2" ge 5.4-3; then
  38.           if [ -e /etc/default/hdparm ]; then  
  39.             echo -n "Moving old /etc/default/hdparm to /etc/hdparm.conf . . "
  40.             mv /etc/default/hdparm /etc/hdparm.conf
  41.             echo "done."
  42.           fi
  43.         fi
  44.       fi
  45.     fi
  46.   fi
  47. fi
  48.  
  49.  
  50.